package com.esri.core.internal.tasks.g;

import com.esri.core.internal.io.handler.h;
import com.esri.core.internal.tasks.TaskListener;
import com.esri.core.internal.tasks.d;
import com.esri.core.io.EsriServiceException;
import com.esri.core.io.UserCredentials;
import com.esri.core.tasks.tilecache.ExportTileCacheParameters;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonParser;

/* loaded from: classes.dex */
public class a extends d<String> {
    private static final long serialVersionUID = 1;
    private boolean a;

    public a(ExportTileCacheParameters exportTileCacheParameters, String str, UserCredentials userCredentials, TaskListener<String> taskListener) {
        super(exportTileCacheParameters, str, userCredentials, taskListener);
        if (!exportTileCacheParameters.validate()) {
            throw new EsriServiceException("At least one parameter is missing or incorrect. Note that the area of interest should be an envelope or polygon");
        }
    }

    public a(ExportTileCacheParameters exportTileCacheParameters, String str, UserCredentials userCredentials) {
        super(exportTileCacheParameters, str, userCredentials);
        if (!exportTileCacheParameters.validate()) {
            throw new EsriServiceException("At least one parameter is missing or incorrect. Note that the area of interest should be an envelope or polygon");
        }
    }

    public boolean a() {
        return this.a;
    }

    public void a(boolean z) {
        this.a = z;
    }

    @Override // com.esri.core.internal.tasks.a
    /* renamed from: b */
    public String execute() throws Exception {
        TaskListener<String> listener;
        StringBuilder sb = new StringBuilder();
        sb.append(getServiceURL());
        sb.append(this.a ? "/estimateExportTilesSize" : "/exportTiles");
        sb.append("/submitJob");
        JsonParser a = h.a(sb.toString(), this.actionInput.generateRequestParams(), false, getServiceCredentials());
        JsonNode readTree = com.esri.core.internal.util.d.a().readTree(a);
        JsonNode findValue = readTree.findValue("jobId");
        String textValue = findValue != null ? findValue.getTextValue() : "";
        if (findValue == null && (listener = getListener()) != null) {
            JsonParser traverse = readTree.traverse();
            traverse.nextToken();
            EsriServiceException fromJson = EsriServiceException.fromJson(traverse);
            traverse.close();
            listener.onError(fromJson);
            listener.onCompletion((short) -1, null);
        }
        a.close();
        return textValue;
    }
}
